<?php
/**
* @version		1.0 : view.html.php marum56
* @package		Joomla
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');


/**
 * HTML View class for the Producent component
 *
 * @static
 * @package	Joomla
 * @subpackage	Serwis maszyn samojezdnych
 * @since 1.0
 */
class WykserViewSerwis extends JView
{
	function display($tpl = null)
	{       
		$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
		$edit = JRequest::getVar('edit',true);
		
		JArrayHelper::toInteger($cid, array(0));

		$db =& JFactory::getDBO();
		
		if ($edit)
			$serwis =& msSerwis::getInstance( $cid[0] );
		else
			$serwis =& msSerwis::getInstance();

		// Binduj obiekt producenta, gdy wracamy po nieudanej
		// probie zapisu danych.
		// W normalnej sytuacji, gdy wyswietlamy szczegoly to
		// obiekt wypelniamy polami z tabeli.
		$post = JRequest::get('post');
		if ($post) {
			$serwis->bind($post);
		}
		
		/*
		 * Lista selekt producentów
		 
		$query = 'SELECT name AS value, name AS text'
		. ' FROM #__producenci AS a'
		. ' WHERE a.registerDate = (SELECT max(registerDate) 
		                            FROM #__producenci
                                            WHERE name = a.name)'
                . ' AND a.del = 0'
 		;
		$db->setQuery( $query );
		$prod[] = JHTML::_('select.option',  '', '- Wybierz producenta -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$prod[] = JHTML::_('select.option',  $obj->value, $obj->text );
		}
		$lists['prod'] 	= JHTML::_('select.genericlist',   $prod, 'n_prod', 'class="inputbox" size="1";"', 'value', 'text', $model->n_prod);

		/*
		 * Lista selekt typów urzadzen
		 
		$query = 'SELECT name AS value, name AS text'
		. ' FROM #__typ_urzadz'
 		;
		$db->setQuery( $query );
		$typ_urzadz[] = JHTML::_('select.option',  '', '- Wybierz typ urządzenia -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$typ_urzadz[] = JHTML::_('select.option',  $obj->value, $obj->text );
		}
		$lists['typ_urzadz'] 	= JHTML::_('select.genericlist',   $typ_urzadz, 'typ_urzadz', 'class="inputbox" size="1";"', 'value', 'text', $model->typ_urzadz);
		*/
	
		$this->assignRef('lists', $lists);	
		$this->assignRef('serwis', $serwis);

		parent::display($tpl);
	}
}
